package com.yonyou.pmclouds.assigninfo.rmiimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.assigninfo.entity.AssignInfoVO;
import com.yonyou.pmclouds.assigninfo.mapper.AssignInfoMapper;
import com.yonyou.pmclouds.assigninfo.rmiitf.IAssignInfoMaintain;
import com.yonyou.pmclouds.basecom.bp.processor.AuditInfoInsertMultiProcessor;
import com.yonyou.pmclouds.basecom.bp.processor.AuditInfoInsertProcessor;
import com.yonyou.pmclouds.basecom.bp.template.MultiInsertBpTemplate;
import com.yonyou.pmclouds.basecom.bp.template.SingleInsertBpTemplate;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;

@Service(version = ApplicationConsts.APPLICATION_VERSION, interfaceClass = IAssignInfoMaintain.class)
public class AssignInfoMaintainImpl implements IAssignInfoMaintain {

    private final AssignInfoMapper assignInfoMapper;

    @Autowired
    public AssignInfoMaintainImpl(AssignInfoMapper assignInfoMapper) {
        this.assignInfoMapper = assignInfoMapper;
    }


    @Override
    public AssignInfoVO insert(AssignInfoVO assignInfoVO) throws BusinessException {
        SingleInsertBpTemplate<AssignInfoVO> bpTemplate = new SingleInsertBpTemplate<>(assignInfoMapper);
        bpTemplate.addBeforeProcessor(new AuditInfoInsertProcessor<AssignInfoVO>());
        return bpTemplate.insert(assignInfoVO);
    }

    @Override
    public AssignInfoVO[] insertBatch(AssignInfoVO[] assignInfoVOS) throws BusinessException {
        MultiInsertBpTemplate<AssignInfoVO> bpTemplate = new MultiInsertBpTemplate<AssignInfoVO>(assignInfoMapper);
        bpTemplate.addBeforeProcessor(new AuditInfoInsertMultiProcessor<AssignInfoVO>());
        return bpTemplate.insert(assignInfoVOS);
    }

    @Override
    public void delete(AssignInfoVO assignInfoVO) throws BusinessException {

    }

    @Override
    public AssignInfoVO update(AssignInfoVO assignInfoVO) throws BusinessException {
        return null;
    }
}
